<template>
  <el-container>
    <el-header>
      <div>
        <img src="../assets/logo.png" alt="" />
        <span>扶贫助农平台</span>
      </div>
      <el-menu
        :default-active="$router.path"
        mode="horizontal"
        router
        background-color="#3f3e3d"
        text-color="#fff"
        active-text-color="#fff"
      >
        <el-menu-item v-for="(item, i) in navList" :key="i" :index="item.path">
          <template slot="title">
            <span>{{ item.title }}</span>
          </template>
        </el-menu-item>
      </el-menu>
    </el-header>
    <el-main>
      <router-view />
    </el-main>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
      navList: [
        { path: "/index", title: "首页" },
        { path: "/pinkunView", title: "贫困户" },
        { path: "/AlleviationView", title: "扶贫" },
        { path: "/volunteerView", title: "志愿者" },
        { path: "/userView", title: "个人中心" },
        { path: "/collectionView", title: "收藏" },
        { path: "/msgboardView", title: "留言板" },
        { path: "/lunbotu", title: "轮播图" },
        { path: "/main", title: "后台管理" },
      ],
      //   indexPath: "/index",
    };
  },
  //   methods: {
  //     watch: {
  //       "$route.path": function () {
  //         window.console.log("watch触发");
  //         this.indexPath = "/" + this.$route.path.split("/")[1];
  //       },
  //     },
  //   },
  //   created() {
  //     this.indexPath = "/" + this.$route.path.split("/")[1];
  //   },
};
</script>
<style scoped lang="scss"  >
.el-header {
  display: flex;
  justify-content: space-between;
  background: #3f3e3d;
  div {
    img {
      width: 50px;
      padding: 5px;
    }
    display: flex;
    align-items: center;
    font-size: 30px;
    color: aliceblue;
  }
}
</style>